#include <iostream>
#include <fstream>
#include <sstream>
#include <cassert>
#include <cstring>
#include <string>
using namespace std;

int main(int argn ,char**argv){
	assert(strlen(argv[1])!=0);
	fstream in(argv[1]);
	string line;
	while(getline(in,line)){
		int len = line.size();
		int i = 0;
		for(; i<len; ++i){
			if(line[i]==',') break;
		}
		int j = i+1;
		for(; j<len; ++j){
			if(line[j]==',') break;
		}
		int k = j+1;
		for(; k<len; ++k){
			if(line[k]==',') break;
		}
		int l = k+1;
		for(; l<len; ++l){
			if(line[l]==',') break;
		}

		string filename;
		filename = "province/";
		if(0 != j-(i+1)){
			filename += line.substr(i+1,j-(i+1));
		}else if(0 != k-(j+1)){
			filename += line.substr(j+1,k-(j+1));
		}else if(0 != l-(k+1)){
			filename += line.substr(k+1,l-(k+1));
		}

		filename+=".csv";
		ofstream file;
		file.open(filename.c_str(),ofstream::out | ofstream::app);
		file << line << endl;
		file.close();
	}
	return 0;
}
